<?php
namespace Jammiest\SwigeCore\Servers;

use Jammiest\SwigeCore\Servers\Http;
use Jammiest\SwigeCore\Servers\Tcp;
use Jammiest\SwigeCore\Servers\WebSocket;

class ServerFactory
{
    public function __construct(protected \Psr\Container\ContainerInterface $container)
    {
        
    }
    public function create(string $type,array $config): \Swoole\Server
    {
        return match ($type) {
            'http' => Http::getInstance($config,$this->container),
            'websocket' => WebSocket::getInstance($config,$this->container),
            'tcp' => Tcp::getInstance($config,$this->container),
            default => throw new \InvalidArgumentException("Unsupported server type:{$type}")
        };
    }
}
